﻿using OpenTK;
using OpenTK.Graphics;

namespace Chimp.Core
{
    public class UILabel : ChimpWidget
    {
        public bool IsLink;

        public UILabel(float x, float y, string txt, ChimpWidget p) : base(new Vector2(x, y), new Vector2(128, 30), p)
        {
            Text = txt;
            Color = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
            Alpha = 1.0f;
        }

        public override bool PointInsideWidget(float x, float y)
        {
            if (IsLink)
                return base.PointInsideWidget(x, y);
            return false;
        }

        public override void OnRender()
        {
            ChimpDraw.TextColor = new Vector4(Color.R, Color.G, Color.B, GlobalAlpha);
            ChimpDraw.Text(GlobalPos, Text);
        }

        public override void OnSceneRender()
        {
            ChimpText.ChimpTextCache txt = ChimpDraw.CheckText(Text);
            ChimpDraw.BlendMode = ChimpBlend.Alpha;
            ChimpDraw.Image(new Vector4(DrawPos.X - txt.Width/2, DrawPos.Y - txt.Height/2, txt.Width, txt.Height),
                            txt.Visual, new Vector4(Color.R, Color.G, Color.B, Alpha));
        }
    }
}